<?php
namespace app\admin\controller;

use app\admin\widget\Name;
use app\common\cache\common\IAreaCache;
use app\common\cache\loan\ILoanAgencyCache;
use app\common\cache\loan\ILoanCache;
use app\common\cache\loan\ILoanFavoriteCache;
use app\common\cache\loan\ILoanRecommendCache;
use app\common\cache\loan\ILoanTagCache;
use app\common\controller\AdminBaseController;
use app\common\enum\LoanStatus;
use app\common\enum\IsDelete;
use app\common\ext\IDb;
use app\common\ext\ILog;
use app\common\ext\IRequest;
use think\Db;

class Loan extends AdminBaseController{

    /**
     * @功能：已上架贷款列表
     * @开发者：cxl
     * @return string
     */
    public function loan_up_list(){
        //接收参数
        $loan_agency_type = IRequest::get('loan_agency_type');
        $loan_agency_id = IRequest::get('loan_agency_id');
        $loan_product_id = IRequest::get('loan_product_id');
        $loan_product_name = IRequest::get('loan_product_name');
        $loan_status = IRequest::get('loan_status');
        $loan_pledge = IRequest::get('loan_pledge');
        $loan_repayment = IRequest::get('loan_repayment');
        $loan_identity = IRequest::get('loan_identity');
        $area = IRequest::get("area");

        //整理区域数据
        $province_id = 0;
        $city_id = 0;
        if(!empty($area) && is_array($area)){
            if(!empty($area[0])) $province_id = $area[0];
            if(!empty($area[1])) $city_id = $area[1];
        }

        //判断城市是否正确
        $area_where = null;
        if(!empty($province_id) && !empty($city_id)){
            $area_where = " and ((province is null and city is null) or (province='{$province_id}' and city is null) or (province='{$province_id}' and city ='{$city_id}'))";
        }else{
            if(!empty($province_id)){
                $area_where = " and (province is null or province='{$province_id}')";
            }
        }

        //设置查询条件
        $loan_product_where = null;
        $loan_product_where['ct.is_delete'] = IsDelete::No;
        $loan_product_where['ct.loan_status'] = LoanStatus::release;
        if(!empty($loan_agency_type)) $loan_product_where['ct.loan_agency_type'] = $loan_agency_type;
        if(!empty($loan_agency_id)) $loan_product_where['ct.loan_agency_id'] = $loan_agency_id;
        if(!empty($loan_product_id)) $loan_product_where['ct.loan_product_id'] = $loan_product_id;
        if(!empty($loan_product_name)) $loan_product_where['ct.loan_product_name'] = array("like","%{$loan_product_name}%");
        if(!empty($loan_status) && in_array($loan_status,array(LoanStatus::release))) $loan_product_where['ct.loan_status'] = $loan_status;
        if(!empty($loan_pledge)) $loan_product_where['ct.loan_pledge'] = $loan_pledge;
        if(!empty($loan_repayment)) $loan_product_where['ct.loan_repayment'] = $loan_repayment;
        if(!empty($loan_identity)) $loan_product_where['']=array("exp","find_in_set({$loan_identity}, ct.loan_identity_list)");

        //取得管理员详情
        $loan_list = IDb::getInstance('loan_product as ct')
            ->setDbJoin("loan_product_area as cpa","ct.loan_product_id = cpa.loan_product_id {$area_where}")
            ->setDbWhere($loan_product_where)
            ->setDbOrder("ct.loan_product_id desc")
            ->setDbGroup("ct.loan_product_id")
            ->pag();
        if ($loan_list === false){
            error('获取管理员列表失败');
        }

        //取得城市列表
        $area_list = IAreaCache::getAllList(2);

        //页面赋值
        $this->assign("loan_agency_type",$loan_agency_type);
        $this->assign("loan_agency_id",$loan_agency_id);
        $this->assign("loan_product_id",$loan_product_id);
        $this->assign("loan_product_name",$loan_product_name);
        $this->assign("loan_status",$loan_status);
        $this->assign("loan_pledge",$loan_pledge);
        $this->assign("loan_repayment",$loan_repayment);
        $this->assign("loan_identity",$loan_identity);
        $this->assign("loan_list",$loan_list);
        $this->assign("area_list",$area_list);
        $this->assign("area",$area);

        //渲染模板输出
        return view("loan_up_list");
    }

    /**
     * @功能：编辑中贷款产品列表
     * @开发者：cxl
     * @return string
     */
    public function loan_edit_list(){
        //接收参数
        $loan_agency_id = IRequest::get('loan_agency_id');
        $loan_product_id = IRequest::get('loan_product_id');
        $loan_product_name = IRequest::get('loan_product_name');
        $loan_status = IRequest::get('loan_status');
        $loan_pledge = IRequest::get('loan_pledge');
        $loan_repayment = IRequest::get('loan_repayment');
        $loan_identity = IRequest::get('loan_identity');
        $area = IRequest::get("area");

        //整理区域数据
        $province_id = 0;
        $city_id = 0;
        if(!empty($area) && is_array($area)){
            if(!empty($area[0])) $province_id = $area[0];
            if(!empty($area[1])) $city_id = $area[1];
        }

        //判断城市是否正确
        $area_where = null;
        if(!empty($province_id) && !empty($city_id)){
            $area_where = " and ((province is null and city is null) or (province='{$province_id}' and city is null) or (province='{$province_id}' and city ='{$city_id}'))";
        }else{
            if(!empty($province_id)){
                $area_where = " and (province is null or province='{$province_id}')";
            }
        }

        //设置查询条件
        $loan_product_where = null;
        $loan_product_where['ct.is_delete'] = IsDelete::No;
        $loan_product_where['ct.loan_status'] = array("in",array(loanStatus::edit,loanStatus::audit,loanStatus::audit_failure,loanStatus::down));
        if(!empty($loan_agency_id)) $loan_product_where['ct.loan_agency_id'] = $loan_agency_id;
        if(!empty($loan_product_id)) $loan_product_where['ct.loan_product_id'] = $loan_product_id;
        if(!empty($loan_product_name)) $loan_product_where['ct.loan_product_name'] = array("like","%{$loan_product_name}%");
        if(!empty($loan_status) && !in_array($loan_status,array(loanStatus::release))) $loan_product_where['ct.loan_status'] = $loan_status;
        if(!empty($loan_pledge)) $loan_product_where['ct.loan_pledge'] = $loan_pledge;
        if(!empty($loan_repayment)) $loan_product_where['ct.loan_repayment'] = $loan_repayment;
        if(!empty($loan_identity)) $loan_product_where[''] = array("exp","find_in_set({$loan_identity}, ct.loan_identity_list)");

        //取得管理员详情
        $loan_list = IDb::getInstance('loan_product as ct')
            ->setDbJoin("loan_product_area as cpa","ct.loan_product_id = cpa.loan_product_id {$area_where}")
            ->setDbWhere($loan_product_where)
            ->setDbOrder("ct.loan_product_id desc")
            ->setDbGroup("ct.loan_product_id")
            ->pag();
        if ($loan_list === false){
            error('获取管理员列表失败');
        }

        //取得城市列表
        $area_list = IAreaCache::getAllList(2);

        //页面赋值
        $this->assign("loan_agency_id",$loan_agency_id);
        $this->assign("loan_product_id",$loan_product_id);
        $this->assign("loan_product_name",$loan_product_name);
        $this->assign("loan_status",$loan_status);
        $this->assign("loan_pledge",$loan_pledge);
        $this->assign("loan_repayment",$loan_repayment);
        $this->assign("loan_identity",$loan_identity);
        $this->assign("loan_list",$loan_list);
        $this->assign("area_list",$area_list);
        $this->assign("area",$area);

        //渲染模板输出
        return view("loan_edit_list");
    }

    /**
     * @功能：已删除贷款列表
     * @开发者：cxl
     * @return string
     */
    public function loan_del_list(){
        //接收参数
        $loan_product_id = IRequest::get('loan_product_id');
        $loan_product_name = IRequest::get('loan_product_name');
        $loan_status = IRequest::get('loan_status');
        $loan_pledge = IRequest::get('loan_pledge');
        $loan_repayment = IRequest::get('loan_repayment');
        $loan_identity = IRequest::get('loan_identity');
        $area = IRequest::get("area");

        //整理区域数据
        $province_id = 0;
        $city_id = 0;
        if(!empty($area) && is_array($area)){
            if(!empty($area[0])) $province_id = $area[0];
            if(!empty($area[1])) $city_id = $area[1];
        }

        //判断城市是否正确
        $area_where = null;
        if(!empty($province_id) && !empty($city_id)){
            $area_where = " and ((province is null and city is null) or (province='{$province_id}' and city is null) or (province='{$province_id}' and city ='{$city_id}'))";
        }else{
            if(!empty($province_id)){
                $area_where = " and (province is null or province='{$province_id}')";
            }
        }

        //设置查询条件
        $loan_product_where['ct.is_delete'] = IsDelete::Yes;
        if(!empty($loan_product_id)) $loan_product_where['ct.loan_product_id'] = $loan_product_id;
        if(!empty($loan_product_name)) $loan_product_where['ct.loan_product_name'] = array("like","%{$loan_product_name}%");
        if(!empty($loan_status)) $loan_product_where['ct.loan_status'] = $loan_status;
        if(!empty($loan_pledge)) $loan_product_where['ct.loan_pledge'] = $loan_pledge;
        if(!empty($loan_repayment)) $loan_product_where['ct.loan_repayment'] = $loan_repayment;
        if(!empty($loan_identity)) $loan_product_where[''] =  array("exp","find_in_set({$loan_identity}, ct.loan_identity_list)");

        //取得管理员详情
        $loan_list = IDb::getInstance('loan_product as ct')
            ->setDbJoin("loan_product_area as cpa","ct.loan_product_id = cpa.loan_product_id {$area_where}")
            ->setDbWhere($loan_product_where)
            ->setDbOrder("ct.loan_product_id desc")
            ->setDbGroup("ct.loan_product_id")
            ->pag();
        if ($loan_list === false){
            error('获取管理员列表失败');
        }

        //取得城市列表
        $area_list = IAreaCache::getAllList(2);

        //页面赋值
        $this->assign("loan_product_id",$loan_product_id);
        $this->assign("loan_product_name",$loan_product_name);
        $this->assign("loan_status",$loan_status);
        $this->assign("loan_pledge",$loan_pledge);
        $this->assign("loan_repayment",$loan_repayment);
        $this->assign("loan_identity",$loan_identity);
        $this->assign("loan_list",$loan_list);
        $this->assign("area_list",$area_list);
        $this->assign("area",$area);

        //渲染模板输出
        return view("loan_del_list");
    }

    /**
     * @功能：贷款详情
     * @开发者：cxl
     * @return string
     */
    public function loan_info(){
        //接收参数
        $loan_product_id = IRequest::get("loan_product_id",IRequest::NOT_EMPTY,"贷款编号不能为空！");

        //取得属性分类列表
        $area_list = IAreaCache::getAllList(2);

        //取得贷款信息
        $loan_info = ILoanCache::getInfo($loan_product_id);

        //判断详情数据是否存在
        $product_area_list = array();
        if(!empty($loan_info)){
            //整理币种
            $loan_info['loan_content_img'] = explode(",",$loan_info['loan_content_img']);
            $loan_info['loan_identity_list'] = explode(",",$loan_info['loan_identity_list']);

            //取得所在区域信息
            $loan_product_area_where = null;
            $loan_product_area_where['loan_product_id'] = $loan_product_id;
            $loan_product_area_where['province'] = array("exp","is not null");
            $loan_product_area_where['city'] = array("exp","is not null");
            $product_area_list = IDb::getInstance('loan_product_area')->setDbFiled("province,city")->setDbWhere($loan_product_area_where)->sel();
            if($product_area_list === false){
                $product_area_list = array();
            }
        }

        //设置layout
        $this->layout("layout_empty");

        //页面赋值
        $this->assign("loan_product_id",$loan_product_id);
        $this->assign("loan_info",$loan_info);
        $this->assign("area_list",$area_list);
        $this->assign("product_area_list",$product_area_list);

        //渲染模板输出
        return view();
    }

    /**
     * @功能：贷款日志
     * @开发者：cxl
     * @return string
     */
    public function loan_log(){
        //接收参数
        $loan_product_id = IRequest::get("loan_product_id",IRequest::NOT_EMPTY,"贷款编号不能为空！");

        //取得日志
        $loan_product_log_where['loan_product_id'] = $loan_product_id;
        $loan_product_log_list = IDb::getInstance('loan_product_log')->setDbWhere($loan_product_log_where)->setDbOrder("loan_product_log_id desc")->pag();

        //设置layout
        $this->layout("layout_empty");

        //页面赋值
        $this->assign("loan_product_log_list",$loan_product_log_list);

        //渲染模板输出
        return view();
    }

    /**
     * @功能：提交审核
     * @开发者：cxl
     * @return string
     */
    public function loan_commit(){
        //接收参数
        $loan_product_id = IRequest::get("loan_product_id",IRequest::NOT_EMPTY,"贷款编号不能为空！");

        //开启事物
        IDb::dbStartTrans();

        //修改管理员信息
        $loan_product_where['loan_product_id'] = $loan_product_id;
        $loan_product_data['loan_status'] = loanStatus::audit;
        $loan_product_data['update_time'] = get_date_time();
        $loan_upd = IDb::getInstance('loan_product')->setDbWhere($loan_product_where)->setDbData($loan_product_data)->upd();
        if($loan_upd === false){
            //事物回滚
            IDb::dbRollback();

            //提示错误信息
            error("贷款提交审核失败！");
        }

        //添加操作日志
        $loan_log_add = ILog::LoanLog($loan_product_id,get_login_admin_id(),null,"贷款提交审核！");
        if ($loan_log_add === false) {
            //事物回滚
            IDb::dbRollback();

            //提示错误信息
            error("贷款提交审核失败！");
        }

        //提交事物处理
        IDb::dbCommit();

        //清除缓存
        ILoanCache::deleteInfo($loan_product_id);
        ILoanCache::deleteList();
        ILoanRecommendCache::deleteList();
        ILoanFavoriteCache::deleteListAll();

        //画面跳转
        $this->success("操作成功！");
    }

    /**
     * @功能：贷款审核
     * @开发者：cxl
     * @return string
     */
    public function loan_audit(){
        //接收参数
        $loan_product_id = IRequest::get("loan_product_id",IRequest::NOT_EMPTY,"贷款编号不能为空！");

        //取得属性分类列表
        $area_list = IAreaCache::getAllList(2);

        //取得贷款信息
        $loan_info = ILoanCache::getInfo($loan_product_id);

        //判断详情数据是否存在
        $product_area_list = array();
        if(!empty($loan_info)){
            //整理币种
            $loan_info['loan_content_img'] = explode(",",$loan_info['loan_content_img']);
            $loan_info['loan_identity_list'] = explode(",",$loan_info['loan_identity_list']);

            //取得所在区域信息
            $loan_product_area_where = null;
            $loan_product_area_where['loan_product_id'] = $loan_product_id;
            $loan_product_area_where['province'] = array("exp","is not null");
            $loan_product_area_where['city'] = array("exp","is not null");
            $product_area_list = IDb::getInstance('loan_product_area')->setDbFiled("province,city")->setDbWhere($loan_product_area_where)->sel();
            if($product_area_list === false){
                $product_area_list = array();
            }
        }

        //页面赋值
        $this->assign("loan_product_id",$loan_product_id);
        $this->assign("loan_info",$loan_info);
        $this->assign("area_list",$area_list);
        $this->assign("product_area_list",$product_area_list);

        //渲染模板输出
        return view();
    }

    /**
     * @功能：贷款审核提交
     * @开发者：cxl
     * @return string
     */
    public function loan_audit_submit(){
        //接收参数
        $loan_product_id = IRequest::get("loan_product_id",IRequest::NOT_EMPTY,"贷款编号不能为空！");
        $loan_status = IRequest::get("loan_status",IRequest::NOT_EMPTY,"贷款编号不能为空！");
        $audit_note = IRequest::get("audit_note");

        //开启事物
        IDb::dbStartTrans();

        //修改管理员信息
        $loan_product_where['loan_product_id'] = $loan_product_id;
        $loan_product_data['loan_status'] = $loan_status;
        $loan_product_data['audit_note'] = $audit_note;
        $loan_product_data['update_time'] = get_date_time();
        $loan_upd = IDb::getInstance('loan_product')->setDbWhere($loan_product_where)->setDbData($loan_product_data)->upd();
        if($loan_upd === false){
            //事物回滚
            IDb::dbRollback();

            //提示错误信息
            error("贷款审核错误！");
        }

        //添加操作日志
        $loan_log_add = ILog::LoanLog($loan_product_id,get_login_admin_id(),null,"贷款审核！");
        if ($loan_log_add === false) {
            //事物回滚
            IDb::dbRollback();

            //提示错误信息
            error("贷款审核错误！");
        }

        //提交事物处理
        IDb::dbCommit();

        //清除缓存
        ILoanCache::deleteInfo($loan_product_id);
        ILoanCache::deleteList();
        ILoanCache::deletePcList();
        ILoanRecommendCache::deleteList();
        ILoanFavoriteCache::deleteListAll();

        //画面跳转
        $this->success("操作成功！",Url("loan_edit_list"));
    }

    /**
     * @功能：贷款下架
     * @开发者：cxl
     * @return string
     */
    public function loan_down(){
        //接收参数
        $loan_product_id = IRequest::get("loan_product_id",IRequest::NOT_EMPTY,"贷款编号不能为空！");

        //开启事物出来
        IDb::dbStartTrans();

        //修改管理员信息
        $loan_product_where['loan_product_id'] = $loan_product_id;
        $loan_product_data['loan_status'] = loanStatus::down;
        $loan_product_data['update_time'] = get_date_time();
        $loan_upd = IDb::getInstance('loan_product')->setDbWhere($loan_product_where)->setDbData($loan_product_data)->upd();
        if($loan_upd === false){
            //事物回滚
            IDb::dbRollback();

            //错误信息
            error("贷款下架失败！");
        }

        //修改管理员信息
        $loan_recommend_where['loan_product_id'] = $loan_product_id;
        $loan_recommend_data['is_delete'] = IsDelete::Yes;
        $loan_recommend_data['update_admin'] = get_login_admin_id();
        $loan_recommend_data['update_time'] = get_date_time();
        $loan_recommend_upd = IDb::getInstance('loan_recommend')->setDbWhere($loan_recommend_where)->setDbData($loan_recommend_data)->upd();
        if($loan_recommend_upd === false){
            //事物回滚
            IDb::dbRollback();

            //错误信息
            error("贷款推荐删除失败！");
        }

        //添加操作日志
        $loan_log_add = ILog::LoanLog($loan_product_id,get_login_admin_id(),null,"贷款下架！");
        if ($loan_log_add === false) {
            //事物回滚
            IDb::dbRollback();

            //提示错误信息
            error("贷款下架失败！");
        }

        //事物提交
        IDb::dbCommit();

        //清除缓存
        ILoanCache::deleteInfo($loan_product_id);
        ILoanCache::deleteList();
        ILoanCache::deletePcList();
        ILoanRecommendCache::deleteList();
        ILoanFavoriteCache::deleteListAll();

        //画面跳转
        $this->success("操作成功！");
    }

    /**
     * @功能：贷款删除
     * @开发者：cxl
     * @return string
     */
    public function loan_del(){
        //接收参数
        $loan_product_id = IRequest::get("loan_product_id",IRequest::NOT_EMPTY,"贷款编号不能为空！");

        //开启事物出来
        IDb::dbStartTrans();

        //修改管理员信息
        $loan_product_where['loan_product_id'] = $loan_product_id;
        $loan_product_data['is_delete'] = IsDelete::Yes;
        $loan_product_data['update_time'] = get_date_time();
        $loan_upd = IDb::getInstance('loan_product')->setDbWhere($loan_product_where)->setDbData($loan_product_data)->upd();
        if($loan_upd === false){
            //事物回滚
            IDb::dbRollback();

            //错误信息
            error("贷款删除失败！");
        }

        //修改管理员信息
        $loan_recommend_where['loan_product_id'] = $loan_product_id;
        $loan_recommend_data['is_delete'] = IsDelete::Yes;
        $loan_recommend_data['update_admin'] = get_login_admin_id();
        $loan_recommend_data['update_time'] = get_date_time();
        $loan_recommend_upd = IDb::getInstance('loan_recommend')->setDbWhere($loan_recommend_where)->setDbData($loan_recommend_data)->upd();
        if($loan_recommend_upd === false){
            //事物回滚
            IDb::dbRollback();

            //错误信息
            error("贷款删除失败！");
        }

        //添加操作日志
        $loan_log_add = ILog::LoanLog($loan_product_id,get_login_admin_id(),null,"贷款删除！");
        if ($loan_log_add === false) {
            //事物回滚
            IDb::dbRollback();

            //提示错误信息
            error("贷款删除失败！");
        }

        //事物提交
        IDb::dbCommit();

        //清除缓存
        ILoanCache::deleteInfo($loan_product_id);
        ILoanCache::deleteList();
        ILoanRecommendCache::deleteList();
        ILoanFavoriteCache::deleteListAll();

        //画面跳转
        $this->success("操作成功！");
    }

    /**
     * @功能：贷款还原
     * @开发者：cxl
     * @return string
     */
    public function loan_recycle(){
        //接收参数
        $loan_product_id = IRequest::get("loan_product_id",IRequest::NOT_EMPTY,"贷款编号不能为空！");

        //开启事物出来
        IDb::dbStartTrans();

        //修改管理员信息
        $loan_product_where['loan_product_id'] = $loan_product_id;
        $loan_product_data['is_delete'] = IsDelete::No;
        $loan_product_data['update_time'] = get_date_time();
        $loan_upd = IDb::getInstance('loan_product')->setDbWhere($loan_product_where)->setDbData($loan_product_data)->upd();
        if($loan_upd === false){
            //事物回滚
            IDb::dbRollback();

            //提示错误信息
            error("贷款还原失败！");
        }

        //添加操作日志
        $loan_log_add = ILog::LoanLog($loan_product_id,get_login_admin_id(),null,"贷款还原！");
        if ($loan_log_add === false) {
            //事物回滚
            IDb::dbRollback();

            //提示错误信息
            error("贷款还原失败！");
        }

        //事物提交
        IDb::dbCommit();

        //清除缓存
        ILoanCache::deleteInfo($loan_product_id);
        ILoanCache::deleteList();
        ILoanRecommendCache::deleteList();
        ILoanFavoriteCache::deleteListAll();

        //画面跳转
        $this->success("操作成功！");
    }

    /**
     * @功能：贷款推荐
     * @开发者：cxl
     * @return string
     */
    public function loan_recommend(){
        //接收参数
        $loan_product_id = IRequest::get("loan_product_id",IRequest::NOT_EMPTY,"贷款编号不能为空！");

        //页面赋值
        $this->assign("loan_product_id",$loan_product_id);

        //渲染模板输出
        return view();
    }

    /**
     * @功能：贷款推荐
     * @开发者：cxl
     * @return string
     */
    public function loan_recommend_submit(){
        //接收参数
        $loan_product_id = IRequest::get("loan_product_id",IRequest::NOT_EMPTY,"贷款编号不能为空！");
        $loan_recommend_id = IRequest::get("loan_recommend_id",IRequest::NOT_EMPTY,"贷款推荐位置编号不能为空！");
        $loan_note = IRequest::get("loan_note");
        $order_by = IRequest::get("order_by");
        $remark = IRequest::get("remark");

        //查看是否存在历史数据
        $where = null;
        $where['loan_product_id'] = $loan_product_id;
        $where['loan_recommend_location'] = $loan_recommend_id;
        $loan_tag_count = IDb::getInstance('loan_recommend')->setDbWhere($where)->con();
        if($loan_tag_count > 0){
            //修改数据
            $data = null;
            $data['loan_note'] = $loan_note;
            $data['order_by'] = $order_by;
            $data['remark'] = $remark;
            $data['is_delete'] = IsDelete::No;
            $data['create_admin'] = get_login_admin_id();
            $data['create_time'] = get_date_time();
            $loan_tag_upd = IDb::getInstance('loan_recommend')->setDbWhere($where)->setDbData($data)->upd();
            if($loan_tag_upd == false){
                error("推荐失败！");
            }
        }else{
            //修改数据
            $data = null;
            $data['loan_product_id'] = $loan_product_id;
            $data['loan_recommend_location'] = $loan_recommend_id;
            $data['loan_note'] = $loan_note;
            $data['order_by'] = $order_by;
            $data['remark'] = $remark;
            $data['update_admin'] = get_login_admin_id();
            $data['update_time'] = get_date_time();
            $loan_tag_add = IDb::getInstance('loan_recommend')->setDbWhere($where)->setDbData($data)->add();
            if($loan_tag_add == false){
                error("推荐失败！");
            }
        }

        //清除缓存
        ILoanRecommendCache::deleteList();

        //画面跳转
        $this->success("操作成功！",Url("loan_up_list"));
    }

    /**
     * @功能：贷款产品分享记录
     * @开发者：cxl
     * @return string
     */
    public function loan_share_log(){
        //接收参数
        $user_id = IRequest::get("user_id");
        $loan_product_id = IRequest::get("loan_product_id");

        //取得数据
        $where = array();
        if(!empty($user_id)) $where['user_id'] = $user_id;
        if(!empty($loan_product_id)) $where['loan_product_id'] = $loan_product_id;
        $loan_share_list = IDb::getInstance("loan_share")
            ->setDbWhere($where)
            ->pag();

        //页面赋值
        $this->assign("user_id",$user_id);
        $this->assign("loan_product_id",$loan_product_id);
        $this->assign("loan_share_list",$loan_share_list);

        //渲染模板输出
        return view();
    }
}
